﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Surface.Presentation;

namespace LetsGoToSchool
{
    /// <summary>
    /// Interaction logic for HelpVideoBox.xaml
    /// Bring up the help video to guide the kid
    /// </summary>
    public partial class HelpVideoBox : UserControl
    {
        private MediaPlayer player;

        public HelpVideoBox()
        {
            this.InitializeComponent();
            player = new MediaPlayer();
        }

        public void playMovie(String Filename)
        {
            player.Open(new Uri(@Filename));
            MediaRect.Fill = getVideoBrush(new Rect(new Point(0, 0), new Size(MediaRect.Width, MediaRect.Height)));
            player.Play();
            player.Volume = 0.5;
        }

        private DrawingBrush getVideoBrush(Rect r)
        {
            VideoDrawing draw = new VideoDrawing();
            draw.Rect = r;
            draw.Player = player;

            DrawingBrush db = new DrawingBrush(draw);
            return db;
        }

        public void Close()
        {
            player.Stop();
            MediaRect.Fill = null;
        }

        private void _quitButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
            this.Visibility = Visibility.Hidden;
            (this.Parent as Canvas).Visibility = Visibility.Hidden;
        }
    }
}
